// Decompiled by GOOSIN CO,LTD Copyright 2010 Pavel Kouznetsov.
// home page: http://www.Goosin.net
// Decompiler options: packimports(3) fieldsfirst ansi space 
// Source File Name:   check_ok.java

package oa.culture;

import include.nseer_db.nseer_db_backup1;
import java.io.IOException;
import java.sql.ResultSet;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.*;
import javax.servlet.jsp.JspFactory;

public class check_ok extends HttpServlet
{

	public check_ok()
	{
	}

	public synchronized void service(HttpServletRequest request, HttpServletResponse response)
		throws IOException, ServletException
	{
		HttpSession dbSession = request.getSession();
		JspFactory _jspxFactory = JspFactory.getDefaultFactory();
		javax.servlet.jsp.PageContext pageContext = _jspxFactory.getPageContext(this, request, response, "", true, 8192, true);
		ServletContext dbApplication = dbSession.getServletContext();
		try
		{
			HttpSession session = request.getSession();
			ServletContext context = session.getServletContext();
			String path = context.getRealPath("/");
			nseer_db_backup1 oa_db = new nseer_db_backup1(dbApplication);
			if (oa_db.conn((String)dbSession.getAttribute("unit_db_name")))
			{
				String config_id = request.getParameter("config_id");
				String check_time = request.getParameter("check_time");
				String checker = request.getParameter("checker");
				String checker_ID = request.getParameter("checker_ID");
				String culture_ID = request.getParameter("culture_ID");
				String sql1 = (new StringBuilder("select * from oa_culture where culture_ID='")).append(culture_ID).append("' and check_tag='0'").toString();
				ResultSet rs = oa_db.executeQuery(sql1);
				if (!rs.next())
				{
					response.sendRedirect("oa/culture/check_ok_a.jsp");
				} else
				{
					String sql = (new StringBuilder("update oa_workflow set checker='")).append(checker).append("',checker_ID='").append(checker_ID).append("',check_time='").append(check_time).append("',check_tag='1' where object_ID='").append(culture_ID).append("' and type_id='05' and config_id='").append(config_id).append("'").toString();
					oa_db.executeUpdate(sql);
					sql = (new StringBuilder("select id from oa_workflow where object_ID='")).append(culture_ID).append("' and type_id='05' and check_tag='0'").toString();
					ResultSet rset = oa_db.executeQuery(sql);
					if (!rset.next())
					{
						sql = (new StringBuilder("update oa_culture set checker='")).append(checker).append("',checker_ID='").append(checker_ID).append("',check_time='").append(check_time).append("',check_tag='1' where culture_ID='").append(culture_ID).append("'").toString();
						oa_db.executeUpdate(sql);
					}
					response.sendRedirect("oa/culture/check_ok_b.jsp");
				}
				oa_db.commit();
				oa_db.close();
			} else
			{
				response.sendRedirect("error_conn.htm");
			}
		}
		catch (Exception ex)
		{
			ex.printStackTrace();
		}
	}
}
